<?php
    include_once "../class/user.php";
    include_once "../query.php";
    include_once "../../src/ulit/hyh.php";
    include_once "../../src/requst/request_err.php";
    include_once "../../src/requst/request_succ.php";

    header("Content-Type:text/html;charset=utf-8");
    header('Access-Control-Allow-Methods:*');
    header("Access-Control-Allow-Origin:*");

    $name = $_POST['name'];
    $pass = $_POST['pass'];
    $introduction = $_POST['introduction'];
    $email = $_POST['email'];
    $interest = $_POST['interest'];
    $city = $_POST['city'];
    $address = $_POST['address'];
    $age = $_POST['age'];
    $vx = $_POST['vx'];
    $friends = $_POST['friends'];
    $sex = $_POST['sex'];
    $img = ($sex == '女'?'girl.jpg':'boy.jpg');
    $uid = time();

    $re = new ReError();
    if(!$re->reErr([$name, $pass, $vx, $friends, $sex])) return;
    #--echo(json_encode([$sql_name, $sql_pass, $sql_phone, $sql_role_id, $sql_img]));

    $re = new ReSucc(); #---返回的数据
    $re->data = new stdClass();

    $sql = "INSERT INTO user VALUES (".$uid.", '"
    .$introduction."', '"
    .$img."', '"
    .$sex."', '"
    .$address."', '"
    .$city."', '"
    .$interest."', '"
    .$email."','"
    .$vx."',"
    .$age.",'"
    .$name."','"
    .$friends."','"
    .$pass."')";

    $result=queryEquip($sql);    #---执行查询函数

    if($result === true){
        
        $re->msg = "注册成功!";
        $re->data->state = 'succ';
        $re->data->info = array(
            'name' => $name,
            'pass' => $pass
        );
        if($createTime) $re->data->createTime = $createTime;
        echo json_encode($re);
    }
    else{
        $re = new ReError();
        $re->msg = "数据库错误!";
        $re->data = new stdClass();
        $re->data->state = 'err';
        $re->data->errMsg = $result;
        echo json_encode($re);
    }
?>